package com.twu.biblioteca;

import com.twu.biblioteca.app.Library;
import com.twu.biblioteca.app.book.Book;
import com.twu.biblioteca.app.movie.Movie;
import com.twu.biblioteca.app.movie.MovieRating;
import com.twu.biblioteca.app.user.User;
import com.twu.biblioteca.ui.LoginSerivce;
import com.twu.biblioteca.ui.menus.MainMenu;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

public class BibliotecaApp {
    private static List<Book> libraryBooks = Arrays.asList(
            new Book("Jane Eyre", "Charlotte Bronte"),
            new Book("Great Expectations", "Charles Dickens"),
            new Book("War and Peace", "Leo Tolstoy"));

    private static List<Movie> libraryMovies = Arrays.asList(
            new Movie("The Shawshank Redemption", 1994, "Frank Darabont", MovieRating.NINE),
            new Movie("Fight Club", 1999, "David Fincher", MovieRating.EIGHT),
            new Movie("Contraband", 2012, "Baltasar Kormakur", MovieRating.SIX)
    );

    private static List<User> userRecords = Arrays.asList(
            new User("100-0001", "password", "John Smith", "john.smith@email.com", "0402040020"),
            new User("100-0002", "kittycat", "Jane Smith", "jane.smith@email.com", "0402040020")
    );

    public static void main(String[] args) {
        BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in));
        Library library = new Library(libraryBooks, libraryMovies,userRecords);

        User user = LoginSerivce.login(inputReader, library);

        MainMenu mainMenu = new MainMenu(inputReader, library);
        mainMenu.displayWelcomeScreen();

            while(true) {
                mainMenu.readAndHandleMenuSelection(user);
            }
    }

    public static void exit() {
        System.exit(0);
    }

}
